using System;
using AzManContrib.MVC.FluentApi;
using AzManContrib.MVC.Html.Behaviors;
using AzManContrib.MVC.Initialization;

namespace AzManContrib.MVC
{
    public static class AzMan
    {
        internal static IAzManAuthorizationStore AzManStore;
        internal static IAzManApplication AzManApplication;
        internal static bool Initialized;

        public static void Initialize<TMode>(InitializationContext initializationContext, Action<InitializationSpec> spec)
            where TMode : IAzManInitializationType, new()
        {
            InitializationSpec initializationSpec = new InitializationSpec();
            spec(initializationSpec);

            TMode mode = new TMode();
            mode.Init(initializationContext);
        }

        public static bool IsInitialized
        {
            get { return Initialized; }
        }

        public static IAzManAuthorizationStore Store
        {
            get
            {
                return AzManStore;
            }
        }

        public static IAzManApplication Application
        {
            get
            {
                return AzManApplication;
            }
        }

        public static void Default(Action<DefaultsSpec> spec)
        {
            DefaultsSpec defaults = new DefaultsSpec();
            spec(defaults);
        }

        internal class Defaults
        {
            internal class UI
            {

                private static string _cssClass = "hidden";
                private static Type _denyiedBehavior = typeof(HiddenUIBehavior);

                public static string CssClass
                {
                    get { return _cssClass; }
                    set { _cssClass = value; }
                }

                public static Type DenyiedBehavior
                {
                    get { return _denyiedBehavior; }
                    set { _denyiedBehavior = value; }
                }
            }
        }
    }
}